package cn.zl.ZLM.event.callback.impl;

import cn.zl.ZLM.core.ZLMApi;
import cn.zl.ZLM.event.callback.inter.IMKProxyPlayerCallBack;
import cn.zl.ZLM.helper.ZLMApiHelper;
import cn.zl.ZLM.structure.MK_PROXY_PLAYER;
import cn.zl.common.manage.StreamProxyManage;
import cn.zl.common.manage.data.StreamProxyData;
import com.sun.jna.Pointer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MKProxyPlayerCallBack implements IMKProxyPlayerCallBack {

    private static final Logger logger = LoggerFactory.getLogger(MKProxyPlayerCallBack.class);

    private StreamProxyManage manage;

    private StreamProxyData data;

    public MKProxyPlayerCallBack(StreamProxyManage manage, StreamProxyData data){
        this.manage = manage;
        this.data = data;
    }

    @Override
    public void invoke(Pointer pUser, int err, String what, int sys_err) {
        ZLMApi ZLM_API = ZLMApiHelper.getInstance().getApi();
        ZLM_API.mk_proxy_player_release(new MK_PROXY_PLAYER(pUser));
        manage.stop(data.getProxyId());
        logger.info("[停止-拉流代理] proxy_id:{} app: {} stream: {}", data.getProxyId(), data.getApp(), data.getStream());
    }

}
